package com.scuec.groupfive.mapper;

import com.scuec.groupfive.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; // 导入注解
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserLoginMapper {

    /**
     * 添加 @Param 注解指定参数名
     */
    @Select("SELECT " +
            "user_id AS userId, " +
            "username, " +
            "password, " +
            "email, " +
            "phone, " +
            "real_name AS realName, " +
            "gender, " +
            "avatar, " +
            "school, " +
            "target_school AS targetSchool, " +
            "exam_year AS examYear, " +
            "role, " +
            "status, " +
            "last_login_time AS lastLoginTime, " +
            "created_at AS createdAt, " +
            "updated_at AS updatedAt " +
            "FROM users " +
            "WHERE username = #{username} AND password = #{password}" // 与注解参数名一致
    )
    UserInfo selectByUsernameAndPassword(
            @Param("username") String username, // 明确参数名为 username
            @Param("password") String password  // 明确参数名为 password
    );
}